#!/bin/sh
targetFile=$1

echo 'FROM docker-mirror.ikuko.com/jdk1.8
VOLUME /opt/jar
ADD '${targetFile}' /opt/jar/app.jar
ENV JAVA_OPTS="'${jvmOps}' -Xloggc:/opt/'${JOB_NAME}'-gc.log -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/opt/'${JOB_NAME}'.dump -Dfile.encoding=UTF-8"
ENTRYPOINT java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar /opt/jar/app.jar --spring.profiles.active='${env}'' > ${WORKSPACE}/Dockerfile

echo 'apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app: '${JOB_NAME}'
  name: '${JOB_NAME}'
  namespace: ewt-'${env}' 
spec:
  replicas: 1
  selector:
    matchLabels:
      app: '${JOB_NAME}'
  template:
    metadata:
      labels:
        app: '${JOB_NAME}'
    spec:
      containers:
      - image: docker-mirror.ikuko.com/ewt/'${JOB_NAME}'
        name: '${JOB_NAME}'
        resources:
          limits:
            cpu: 1000m
            memory: 1000Mi
          requests:
            cpu: 500m
            memory: 512Mi' > ${WORKSPACE}/${JOB_NAME}.yaml